package com.station.Activitys.http.manager;

import android.app.Activity;
import android.util.Log;

import com.station.Activitys.bean.ImageJson;
import com.station.Activitys.bean.MyTestMsg;
import com.station.Activitys.bean.State;
import com.station.Activitys.bean.Survey;
import com.station.Activitys.bean.SurveyDetails;
import com.station.Activitys.bean.WorkMapMsg;
import com.station.Activitys.http.ApiService;
import com.station.Activitys.http.NetWorkMgr;
import com.station.Activitys.http.api.WorkAPI;
import com.station.Activitys.utils.Constant;

import org.simple.eventbus.EventBus;

import java.util.List;

import rx.Observer;
import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * 项目名称：
 * 类描述：工单 接口管理 manager
 * 创建人：张飞祥
 * 创建时间：2018/5/9 0027 下午 1:33
 * 修改人：张飞祥
 * 修改时间：2018/5/9 0027 下午 1:33
 * 修改备注：
 */
public class WorkManager {

    private static WorkAPI mWorkAPI;
    private static ApiService mApiService;
    private static Activity mActivity;
    private static int mTaskId;

    //加载数据类型
    private int RefType = Constant.FIRST_LOAD;

    private static class WorkApiManagerHolder {
        private static final WorkManager INSTANCE = new WorkManager();
    }

    public static final WorkManager getWorkApiManager(Activity activity, int taskId) {
        mWorkAPI = NetWorkMgr.getInstance(activity)
                .getServiceAPI(WorkAPI.class);
        mApiService = ApiService.getApiService();
        mActivity = activity;
        mTaskId = taskId;
        return WorkApiManagerHolder.INSTANCE;
    }

    public void getType(int type) {
        RefType = type;
    }

    /**
     * 工单处理 列表
     */
    public void workList(int userId,String PhysicalStationName, String workOrderType, String startTime,
                         String endTime, int pageIndex, int pageSize) {
        Subscription subscription = mWorkAPI
                .workList(userId, PhysicalStationName,workOrderType, startTime,
                        endTime, pageIndex, pageSize).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<List<Survey>>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_LIST_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(List<Survey> list) {
                        if (RefType == Constant.FIRST_LOAD) {
                            //返回成功 首次加载数据处理
                            EventBus.getDefault().post(list, Constant.BUS_WORK_LIST);
                        } else {
                            //返回成功 上拉加载数据处理
                            EventBus.getDefault().post(list, Constant.BUS_WORK_LIST_FOOT);
                        }
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 工单处理 勘察（室分）保存
     */
    public void workRoomSave(int userId, int Id, String StationModel,
                             String Imgs, String AutoGpsX, String AutoGpsY, String ManualInputGpsX,
                             String ManualInputGpsY, int SignalIntensity, String ChamberMolecularSceneType,
                             String FrequencyChannel, String CompartmentType,
                             String CoveringBuildingsFloorsOrLocations, String CoverageArea, String PRRUSourcesNum,
                             String NumberOfRRUSourcesForPassiveCellDivision,
                             String PassiveCellTypeSingleAndDoubleChannelType) {
        Subscription subscription = mWorkAPI
                .workRoomSave(userId, Id, StationModel, Imgs, AutoGpsX, AutoGpsY,
                        ManualInputGpsX, ManualInputGpsY, SignalIntensity, ChamberMolecularSceneType,
                        FrequencyChannel, CompartmentType, CoveringBuildingsFloorsOrLocations, CoverageArea,
                        PRRUSourcesNum, NumberOfRRUSourcesForPassiveCellDivision,
                        PassiveCellTypeSingleAndDoubleChannelType).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<State>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_SURVEY_ROOM_SAVE_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(State state) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(state, Constant.BUS_WORK_SURVEY_ROOM_SAVE);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 工单处理 勘察（室分）提交
     */
    public void workRoomSubmit(int userId, int Id, String StationModel,
                               String Imgs, String AutoGpsX, String AutoGpsY, String ManualInputGpsX,
                               String ManualInputGpsY, int SignalIntensity, String ChamberMolecularSceneType,
                               String FrequencyChannel, String CompartmentType,
                               String CoveringBuildingsFloorsOrLocations, String CoverageArea, String PRRUSourcesNum,
                               String NumberOfRRUSourcesForPassiveCellDivision,
                               String PassiveCellTypeSingleAndDoubleChannelType) {
        Subscription subscription = mWorkAPI
                .workRoomSubmit(userId, Id, StationModel, Imgs, AutoGpsX, AutoGpsY,
                        ManualInputGpsX, ManualInputGpsY, SignalIntensity, ChamberMolecularSceneType,
                        FrequencyChannel, CompartmentType, CoveringBuildingsFloorsOrLocations, CoverageArea,
                        PRRUSourcesNum, NumberOfRRUSourcesForPassiveCellDivision,
                        PassiveCellTypeSingleAndDoubleChannelType).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<State>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_SURVEY_ROOM_SUBMIT_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(State state) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(state, Constant.BUS_WORK_SURVEY_ROOM_SUBMIT);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 工单处理 勘察（非室分）保存
     */
    public void workNotRoomSave(int userId, int Id, String StationModel, String Imgs, String AutoGpsX,
                                String AutoGpsY, String ManualInputGpsX, String ManualInputGpsY,
                                int SignalIntensity, String Height, String AntennaAzimuth, String IsBBUCentralizedDeployment,
                                String SectorAllocation, String RRUPlanningPower, String RRUTransceiverRequirements,
                                String RemotePowerDownAdjustmentIsRequired) {
        Subscription subscription = mWorkAPI
                .workNotRoomSave(userId, Id, StationModel, Imgs, AutoGpsX, AutoGpsY,
                        ManualInputGpsX, ManualInputGpsY, SignalIntensity, Height,
                        AntennaAzimuth, IsBBUCentralizedDeployment,
                        SectorAllocation, RRUPlanningPower, RRUTransceiverRequirements,
                        RemotePowerDownAdjustmentIsRequired).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<State>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_SURVEY_NOT_ROOM_SAVE_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(State state) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(state, Constant.BUS_WORK_SURVEY_NOT_ROOM_SAVE);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 工单处理 勘察（非室分）提交
     */
    public void workNotRoomSubmit(int userId, int Id, String StationModel, String Imgs, String AutoGpsX,
                                  String AutoGpsY, String ManualInputGpsX, String ManualInputGpsY,
                                  int SignalIntensity, String Height, String AntennaAzimuth,
                                  String IsBBUCentralizedDeployment, String SectorAllocation, String RRUPlanningPower,
                                  String RRUTransceiverRequirements, String RemotePowerDownAdjustmentIsRequired) {
        Subscription subscription = mWorkAPI
                .workNotRoomSubmit(userId, Id, StationModel, Imgs, AutoGpsX, AutoGpsY,
                        ManualInputGpsX, ManualInputGpsY, SignalIntensity, Height,
                        AntennaAzimuth, IsBBUCentralizedDeployment,
                        SectorAllocation, RRUPlanningPower, RRUTransceiverRequirements,
                        RemotePowerDownAdjustmentIsRequired).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<State>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_SURVEY_NOT_ROOM_SUBMIT_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(State state) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(state, Constant.BUS_WORK_SURVEY_NOT_ROOM_SUBMIT);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 工单处理 获取详情信息
     */
    public void workDetails(int basestationId) {
        Subscription subscription = mWorkAPI
                .workDetails(basestationId).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<SurveyDetails>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_DETAILS_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(SurveyDetails bean) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(bean, Constant.BUS_WORK_DETAILS);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }


    /**
     * 工单勘察详情 申请规划 提交
     */
    public void workApplayPlanSubmit(int userId, int Id, String Vender, String AreaType, String MainSceneType,
                                     String Priority, String HighSpeedRailwayStation,
                                     String Imgs, String ManualInputGpsX, String ManualInputGpsY, String Height,
                                     String AntennaAzimuth, String IsBBUCentralizedDeployment, String SectorAllocation,
                                     String RRUPlanningPower, String RRUTransceiverRequirements,
                                     String RemotePowerDownAdjustmentIsRequired, String ChamberMolecularSceneType,
                                     String FrequencyChannel, String CompartmentType, String CoveringBuildingsFloorsOrLocations,
                                     String CoverageArea, String PRRUSourcesNum, String NumberOfRRUSourcesForPassiveCellDivision,
                                     String PassiveCellTypeSingleAndDoubleChannelType) {
        Subscription subscription = mWorkAPI
                .workApplayPlanSubmit(userId, Id, Vender,
                        AreaType, MainSceneType, Priority, HighSpeedRailwayStation,
                        Imgs, ManualInputGpsX, ManualInputGpsY, Height,
                        AntennaAzimuth, IsBBUCentralizedDeployment, SectorAllocation,
                        RRUPlanningPower, RRUTransceiverRequirements,
                        RemotePowerDownAdjustmentIsRequired, ChamberMolecularSceneType,
                        FrequencyChannel, CompartmentType, CoveringBuildingsFloorsOrLocations,
                        CoverageArea, PRRUSourcesNum, NumberOfRRUSourcesForPassiveCellDivision,
                        PassiveCellTypeSingleAndDoubleChannelType).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<State>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_APPLY_PLAN_SUBMIT_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(State state) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(state, Constant.BUS_WORK_APPLY_PLAN_SUBMIT);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }


    /**
     * 工单 规划 ---> 申请可研
     */
    public void workPlanApplyStudy(int userId, int Id, String Vender, String AreaType, String MainSceneType,
                                     String Priority, String HighSpeedRailwayStation,
                                     String Imgs, String ManualInputGpsX, String ManualInputGpsY, String Height,
                                     String AntennaAzimuth, String IsBBUCentralizedDeployment, String SectorAllocation,
                                     String RRUPlanningPower, String RRUTransceiverRequirements,
                                     String RemotePowerDownAdjustmentIsRequired, String ChamberMolecularSceneType,
                                     String FrequencyChannel, String CompartmentType, String CoveringBuildingsFloorsOrLocations,
                                     String CoverageArea, String PRRUSourcesNum, String NumberOfRRUSourcesForPassiveCellDivision,
                                     String PassiveCellTypeSingleAndDoubleChannelType,String NumOfProject) {
        Subscription subscription = mWorkAPI
                .workPlanApplyStudy(userId, Id, Vender,
                        AreaType, MainSceneType, Priority, HighSpeedRailwayStation,
                        Imgs, ManualInputGpsX, ManualInputGpsY, Height,
                        AntennaAzimuth, IsBBUCentralizedDeployment, SectorAllocation,
                        RRUPlanningPower, RRUTransceiverRequirements,
                        RemotePowerDownAdjustmentIsRequired, ChamberMolecularSceneType,
                        FrequencyChannel, CompartmentType, CoveringBuildingsFloorsOrLocations,
                        CoverageArea, PRRUSourcesNum, NumberOfRRUSourcesForPassiveCellDivision,
                        PassiveCellTypeSingleAndDoubleChannelType,NumOfProject).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<State>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_PLAN_APPLY_STUDY_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(State state) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(state, Constant.BUS_WORK_PLAN_APPLY_STUDY);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 申请变更
     */
    public void workApplyChange(int userId, int basestationId, String ChangeOfResponsibilityUnit, String causeOfChange) {
        Subscription subscription = mWorkAPI
                .workApplyChange(userId,basestationId,ChangeOfResponsibilityUnit,causeOfChange).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<State>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_APPLY_CHANGE_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(State state) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(state, Constant.BUS_WORK_APPLY_CHANGE);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 工单变更 提交网络请求
     */
    public void workChangeSubmit(int userId, int Id,String Province,String LocalNetworkAddress, String Grid, String PhysicalStationName,
                                 String AddressOfPhysicalStation,String GPS_X, String GPS_Y,String StationModel,
                                   String Vender, String AreaType, String MainSceneType,
                                   String Priority, String HighSpeedRailwayStation,
                                   String Imgs, String AutoGpsX,String AutoGpsY,
                                   String ManualInputGpsX, String ManualInputGpsY,int SignalIntensity, String Height,
                                   String AntennaAzimuth, String IsBBUCentralizedDeployment, String SectorAllocation,
                                   String RRUPlanningPower, String RRUTransceiverRequirements,
                                   String RemotePowerDownAdjustmentIsRequired, String ChamberMolecularSceneType,
                                   String FrequencyChannel, String CompartmentType, String CoveringBuildingsFloorsOrLocations,
                                   String CoverageArea, String PRRUSourcesNum, String NumberOfRRUSourcesForPassiveCellDivision,
                                   String PassiveCellTypeSingleAndDoubleChannelType,String NumOfProject) {
        Subscription subscription = mWorkAPI
                .workChangeSubmit(userId, Id, Province, LocalNetworkAddress, Grid,
                        PhysicalStationName, AddressOfPhysicalStation,GPS_X, GPS_Y,StationModel,Vender,
                        AreaType, MainSceneType, Priority, HighSpeedRailwayStation,
                        Imgs, AutoGpsX, AutoGpsY,  ManualInputGpsX, ManualInputGpsY,SignalIntensity, Height,
                        AntennaAzimuth, IsBBUCentralizedDeployment, SectorAllocation,
                        RRUPlanningPower, RRUTransceiverRequirements,
                        RemotePowerDownAdjustmentIsRequired, ChamberMolecularSceneType,
                        FrequencyChannel, CompartmentType, CoveringBuildingsFloorsOrLocations,
                        CoverageArea, PRRUSourcesNum, NumberOfRRUSourcesForPassiveCellDivision,
                        PassiveCellTypeSingleAndDoubleChannelType,NumOfProject).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<State>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_CHANGE_SUBMIT_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(State state) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(state, Constant.BUS_WORK_CHANGE_SUBMIT);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 工单 可验收信息 列表
     */
    public void workTestMsgList(int pageIndex, int pageSize,String PhysicalStationName,
                                String Province, String LocalNetworkAddress,
                         String Grid,String NumOfProject) {
        Subscription subscription = mWorkAPI
                .workTestMsgList(pageIndex,pageSize,PhysicalStationName, Province,
                        LocalNetworkAddress,Grid,NumOfProject)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<List<Survey>>() {
                    @Override
                    public void onCompleted() {

                    }
                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_TEST_MSG_LIST_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }
                    @Override
                    public void onNext(List<Survey> list) {
                        if (RefType == Constant.FIRST_LOAD) {
                            //返回成功 首次加载数据处理
                            EventBus.getDefault().post(list, Constant.BUS_WORK_TEST_MSG_LIST);
                        } else {
                            //返回成功 上拉加载数据处理
                            EventBus.getDefault().post(list, Constant.BUS_WORK_TEST_MSG_LIST_FOOT);
                        }
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 工单 可验收信息 承接
     */
    public void workTestMsgUndertake(int UserId,int BaseStationId,String DepartMentName) {
        Subscription subscription = mWorkAPI
                .workTestMsgUndertake(UserId, BaseStationId, DepartMentName).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<State>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_TEST_MSG_UNDERTAKE_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(State state) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(state, Constant.BUS_WORK_TEST_MSG_UNDERTAKE);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 工单 可验收信息 列表
     */
    public void workMyTestMsgList(int userId ,int pageIndex, int pageSize) {
        Subscription subscription = mWorkAPI
                .workMyTestMsgList(userId,pageIndex,pageSize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<MyTestMsg>() {
                    @Override
                    public void onCompleted() {

                    }
                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_MY_TEST_MSG_LIST_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }
                    @Override
                    public void onNext(MyTestMsg bean) {
                        if (RefType == Constant.FIRST_LOAD) {
                            //返回成功 首次加载数据处理
                            EventBus.getDefault().post(bean, Constant.BUS_WORK_MY_TEST_MSG_LIST);
                        } else {
                            //返回成功 上拉加载数据处理
                            EventBus.getDefault().post(bean, Constant.BUS_WORK_MY_TEST_MSG_LIST_FOOT);
                        }
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 工单 可验收信息 承接
     */
    public void workMyTestMsgImages(int Id) {
        Subscription subscription = mWorkAPI
                .workMyTestMsgImages(Id).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<List<ImageJson>>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_MY_TEST_MSG_IMAGES_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(List<ImageJson> list) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(list, Constant.BUS_WORK_MY_TEST_MSG_IMAGES);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 工单 可验收信息 承接
     */
    public void workMyTestMsgSubmit(int UserId,int Id, int BaseStationId,
                                    String Province, String LocalNetworkAddress,
                                    String Grid, String Vender, String PhysicalStationName,
                                    String AddressOfPhysicalStation, String AreaType,
                                    String MainSceneType, String StationModel,
                                    String ManualInputGpsX, String ManualInputGpsY,
                                    String AutoGpsX, String AutoGpsY, String IsDeviate,
                                    String DepartMentName,  String NameOfOpenStationAddr,
                                    String NumOfProject, String Imgs, String Priority,
                                    String SignalIntensity) {
        Subscription subscription = mWorkAPI
                .workMyTestMsgSubmit(UserId,Id,BaseStationId, Province, LocalNetworkAddress,
                 Grid,Vender, PhysicalStationName, AddressOfPhysicalStation, AreaType,
                 MainSceneType, StationModel, ManualInputGpsX, ManualInputGpsY,
                 AutoGpsX,  AutoGpsY,IsDeviate, DepartMentName, NameOfOpenStationAddr,
                 NumOfProject, Imgs, Priority, SignalIntensity).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<State>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_MY_TEST_MSG_SUBMIT_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(State state) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(state, Constant.BUS_WORK_MY_TEST_MSG_SUBMIT);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

    /**
     * 基站分布信息
     */
    public void workMapLocationMsg(int userId,String type) {
        Subscription subscription = mWorkAPI
                .workMapLocationMsg(userId, type).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<List<WorkMapMsg>>() {
                    @Override
                    public void onCompleted() {
                    }

                    @Override
                    public void onError(Throwable e) {
                        //返回成功 数据处理
                        EventBus.getDefault().post(e.toString(), Constant.BUS_WORK_MAP_MSG_LIST_ERROR);
                        //log 打印
                        Log.e(mActivity.getClass().getSimpleName(), "structureList 错误" + e.toString());
                    }

                    @Override
                    public void onNext(List<WorkMapMsg> list) {
                        //返回成功 首次加载数据处理
                        EventBus.getDefault().post(list, Constant.BUS_WORK_MAP_MSG_LIST);
                    }
                });
        mApiService.getCompositeSubscription(mTaskId).add(subscription);
    }

}
